#  Copyright (c) 2014-present, Facebook, Inc.
#  All rights reserved.
#
#  This source code is licensed as defined on the LICENSE file found in the
#  root directory of this source tree.

load("//tools/build_defs/oss/osquery:cxx.bzl", "osquery_cxx_test")
load("//tools/build_defs/oss/osquery:native.bzl", "osquery_target")
load("//tools/build_defs/oss/osquery:platforms.bzl", "LINUX", "MACOSX", "POSIX", "WINDOWS")

osquery_cxx_test(
    name = "linux_tests",
    platform_srcs = [
        (
            LINUX,
            [
                "linux/md_tables_tests.cpp",
                "linux/pci_devices_tests.cpp",
                "linux/pcidb_tests.cpp",
                "linux/portage_tests.cpp",
                "linux/selinux_settings_tests.cpp"
            ],
        ),
    ],
    visibility = ["PUBLIC"],
    deps = [
        osquery_target("osquery/config/tests:test_utils"),
        osquery_target("osquery/core:core"),
        osquery_target("osquery/core/sql:core_sql"),
        osquery_target("osquery/database:database"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/remote/tests:remote_test_utils"),
        osquery_target("osquery/utils:utils"),
        osquery_target("osquery/utils/conversions:conversions"),
        osquery_target("plugins/database:ephemeral"),
    ],
)

osquery_cxx_test(
    name = "posix_tests",
    platform_srcs = [
        (
            POSIX,
            [
                "posix/apt_sources_tests.cpp",
                "posix/known_hosts_tests.cpp",
                "posix/shell_history_tests.cpp",
                "posix/sudoers_tests.cpp",
                "posix/yum_sources_tests.cpp",
            ],
        ),
    ],
    visibility = ["PUBLIC"],
    deps = [
        osquery_target("osquery/config/tests:test_utils"),
        osquery_target("osquery/core:core"),
        osquery_target("osquery/core/sql:core_sql"),
        osquery_target("osquery/database:database"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/remote/tests:remote_test_utils"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/utils:utils"),
        osquery_target("osquery/utils/conversions:conversions"),
        osquery_target("plugins/database:ephemeral"),
    ],
)

osquery_cxx_test(
    name = "system_tables_tests",
    srcs = ["system_tables_tests.cpp"],
    visibility = ["PUBLIC"],
    deps = [
        osquery_target("osquery/config/tests:test_utils"),
        osquery_target("osquery/core:core"),
        osquery_target("osquery/core/sql:core_sql"),
        osquery_target("osquery/database:database"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/remote/tests:remote_test_utils"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/utils:utils"),
        osquery_target("osquery/utils/conversions:conversions"),
        osquery_target("plugins/database:ephemeral"),
    ],
)

osquery_cxx_test(
    name = "darwin_tests",
    env = {
        "TEST_CONF_FILES_DIR": "$(location {})".format(
            osquery_target("tools/tests/configs:test_files"),
        ),
    },
    platform_srcs = [
        (
            MACOSX,
            [
                "darwin/apps_tests.cpp",
                "darwin/asl_tests.cpp",
                "darwin/certificates_tests.cpp",
                "darwin/extended_attributes_tests.cpp",
                "darwin/firewall_tests.cpp",
                "darwin/launchd_tests.cpp",
                "darwin/mdfind_tests.cpp",
                "darwin/processes_tests.cpp",
                "darwin/smc_tests.cpp",
                "darwin/startup_items_tests.cpp",
                "darwin/signature_tests.mm",
            ],
        ),
    ],
    visibility = ["PUBLIC"],
    deps = [
        osquery_target("osquery/config/tests:test_utils"),
        osquery_target("osquery/core:core"),
        osquery_target("osquery/core/sql:core_sql"),
        osquery_target("osquery/database:database"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/remote/tests:remote_test_utils"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/utils:utils"),
        osquery_target("osquery/utils/conversions:conversions"),
        osquery_target("plugins/database:ephemeral"),
    ],
)

osquery_cxx_test(
    name = "windows_tests",
    env = {
        "TEST_CONF_FILES_DIR": "$(location {})".format(
            osquery_target("tools/tests/configs:test_files"),
        ),
    },
    platform_srcs = [
        (
            WINDOWS,
            [
                "windows/certificates_tests.cpp",
                "windows/registry_tests.cpp",
                "windows/windows_optional_features_tests.cpp",
            ],
        ),
    ],
    visibility = ["PUBLIC"],
    deps = [
        osquery_target("osquery/config/tests:test_utils"),
        osquery_target("osquery/core:core"),
        osquery_target("osquery/core/sql:core_sql"),
        osquery_target("osquery/database:database"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/filesystem:osquery_filesystem"),
        osquery_target("osquery/remote/tests:remote_test_utils"),
        osquery_target("osquery/tables/system:system_table"),
        osquery_target("osquery/utils:utils"),
        osquery_target("osquery/utils/conversions:conversions"),
        osquery_target("plugins/database:ephemeral"),
    ],
)



